<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
	<link type="text/css" rel="stylesheet" href="./css/manage/style.css">
	<script type="text/javascript" src="<%=basePath%>/script/jquery-1.6.2.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>/script/manage/items.js"></script>
	<style type="text/css">
	.red { color: red; text-align: left; }
	</style>
  </head>
  
  <body>
  	
  		<s:form action="/cas/items_updateorsave.action" id="items_updateorsave" method="post">
    	<table width="100%" class="tab_comm">
    			
    			<s:hidden name="bankstree" id="bankstree"></s:hidden>
    			<s:hidden name="chaptertipstree" id="chaptertipstree"></s:hidden>
				
				<tbody>
					<tr>bankstree: ${bankstree}</tr>
					<tr>chaptertipstree: ${chaptertipstree}</tr>
					<tr>
						<td class="tr fb blue_s">说明:</td>
						<td><s:textarea id="direction" name="item.direction" cssClass="name_text" cssStyle="width: 411px; height: 79px;"/></td>
					</tr>
					<tr>
						<td class="tr fb blue_s">分值:</td>
						<td><s:textfield id="score" name="item.score" cssClass="name_text" maxlength="75"/><span class="red" style="">*</span></td>
					</tr>
					<tr>
						<td class="tr fb blue_s">内容:</td>
						<td><s:textarea id="content" name="item.content" cssClass="name_text" cssStyle="width: 411px; height: 79px;"/></td>
					</tr>
					<tr>
						<td class="tr fb blue_s">题型:</td>
						<td><s:select id="dtype" name="dtype" list="#{'1':'单选','2':'多选','3':'单行文本','4':'多行文本'}" listKey="key" listValue="value" headerKey="-1" headerValue="全部" onchange="selectoption();"/></td>
					</tr>
					<tr id="answer">
						<td class="tr fb blue_s">选项个数:</td>
						<td><s:select id="answers" name="answers" list="#{'1':'1','2':'2','3':'3','4':'4','5':'5','6':'6'}" onchange="answersnumber();"/></td>
					</tr>
					
					<tr>
						<td class="tr fb blue_s"><label>答案：</label></td>
						<td>
							<div id="answershtml"></div>
						</td>
					</tr>
					<tr>
						<td class="tr fb blue_s">解答过程:</td>
						<td><s:textarea id="answerprocess" name="item.answerprocess" cssClass="name_text" cssStyle="width: 411px; height: 79px;"/></td>
					</tr>
					<tr>
						<td class="tr fb blue_s">关键字:</td>
						<td><s:textfield id="keyword" name="item.keyword" cssClass="name_text" maxlength="75"/><span class="red" style="">*</span></td>
					</tr>
					<tr>
						<td class="tr fb blue_s">状态:</td>
						<td><s:select id="status" name="item.status" list="#{'1':'启用','0':'停用'}"/></td>
					</tr>
					<tr>
						<td colspan="2">
						<span class="btnC"><input type="button" value="保存" class="btnC_text" onclick="_submit()"/></span>
						<span class="btnC"><input type="button" value="取消" class="btnC_text" onclick="javascript:window.location.href='./cas/types_index.action'" /></span>
						</td>
					</tr>
				</tbody>
		</s:form>
    
  </body>
  <script type="text/javascript">
  		jQuery(document).ready(function(){
  			jQuery("#answer").hide();
  			jQuery("#answersradio").hide();
  		});
  		function _submit(){
  			document.items_updateorsave.submit();
  		}
  		function selectoption(){
  			var dtype=jQuery("#dtype").val();
  			if(dtype=="1"){
  				jQuery("#answer").show();
  				jQuery("#answershtml").html(gethtmlRadio(1));
  			}else if(dtype=="2"){
  				jQuery("#answer").show();
  				jQuery("#answershtml").html(gethtmlCheckbox(1));
  			}else if(dtype=="3"){
  				jQuery("#answer").hide();
  				jQuery("#answershtml").html(gethtmlinput());
  			}else if(dtype=="4"){
  				jQuery("#answer").hide();
  				jQuery("#answershtml").html(gethtmltextarea());
  			}else{
  				jQuery("#answer").hide();
  				jQuery("#answershtml").html("");
  			}
  		}
  		function answersnumber(){
  			var answers=jQuery("#answers").val();
  			var dtype=jQuery("#dtype").val();
  			var html="";
  			for(var i=1;i<=answers;i++){
  				var ahtml="";
  				if(dtype=="1"){
  					ahtml=gethtmlRadio(i);
  				}else if(dtype=="2"){
  					ahtml=gethtmlCheckbox(i);
  				}
  				html+=ahtml;
  			}
  			jQuery("#answershtml").html(html);
  		}
  </script>

</html>